<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?
require_once  '../classes/ConnectionDB.php';
require_once  '../classes/UtenteManager.php';
require_once  '../classes/TestDataManager.php';
require_once  '../classes/DisciplinaDataManager.php';
require_once  '../bean/Argomento.php';
$connection =ConnectionDB::getInstance()->connectToDB();
$codiceUtente = $_COOKIE['codiceUtente'];

$nomeTest = $_POST['nomeTest'];
$oreTest = $_POST['oreTest'];
$minutiTest = $_POST['minutiTest'];
$codiceDisciplina = $_POST['codiceDisciplina'];

$checks = $_POST['checks'];

$domande = TestDataManager::getInstance()->searchDomandeByCodice($connection, $checks);

$numDomande = count($domande);
$totPunt = 0;
for($j=0; $j<count($domande); $j++)
    $totPunt += $domande[$j]->getPunteggio();
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Nuovo Test - step 3 - </title>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/prototype.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/scriptaculous/effects.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/glassbox/glassbox.js" type="text/javascript"></script>
        <style type="text/css">
            @import url("../css/style.css");
            table{
                width: 100%;
            }

            #tableResults td{
                text-align: center;
            }


            #searchForm {
                padding-top: 3%;
                margin-left: -5px;
            }

            #searchFormCont 
            {
                padding-left: 2%;
            }

            #navigator
            {
                font-size: 14px;
            }

        </style>
        <script type="text/javascript">
            path_to_root_dir = "../glassboxLatest/glassbox.2.0.0/";
            var listaDomande;
            var numItem=10;
            var currentIndex=0;

            window.onload = function()
            {
                var searchForm = new GlassBox();
                searchForm.init( 'searchForm', '840px', '300px', 'hidden','',true, false);
                searchForm.ipos();
                searchForm.appear();

                var results = new GlassBox();
                results.init( 'results', '1040px', '390px', 'auto','',true,false);
                results.ipos();
                results.appear();
            }

            function showDetail(codice)
            {
                location.href="detailQuestion.php?codiceDomanda=" + codice;
            }

            function continua()
            {
                document.getElementById('testForm3').submit();
            }
        </script>
    </head>
    <body>
        <form id="testForm3" method="POST" action="newTestListener.php">
            <input type="hidden" name="checks" id="checks" value="<?= $checks ?>" />
            <input type="hidden" name="nomeTest" value="<?= $nomeTest ?>" />
            <input type="hidden" name="codiceDisciplina" value="<?= $codiceDisciplina ?>" />
            <input type="hidden" name="oreTest" value="<?= $oreTest ?>" />
            <input type="hidden" name="minutiTest" value="<?= $minutiTest ?>" />


        </form>
        <?php include '../portal/header.php';?>
        <center>

            <div id="searchForm">

                <div id="searchFormCont">
                    <table cellpadding="3" style="display: block; padding-left: 70%">

                            <tr>
                                <td colspan="2">&nbsp;</td>
                                <td style="color: gray;">Step 1 - Dettaglio test</td>
                            </tr>
                            <tr>
                                <td colspan="2">&nbsp;</td>
                                <td style="color: gray">Step 2 - Scelta domande</td>
                            </tr>
                             <tr>
                                <td colspan="2">&nbsp;</td>
                                <td style="color: #3e7ad4;"><strong>Step 3 - Conferma test</strong></td>
                            </tr>
                        </table>
                    <table>
                        <tr>
                            <th>Nome test : </th>
                            <td><?= $nomeTest?></td>
                        </tr>
                        <tr>
                            <th>Disciplina : </th>
                            <td><? $tmp = DisciplinaDataManager::getInstance()->getDisciplina($connection, $codiceDisciplina); echo $tmp->getNome(); ?></td>
                        </tr>
                        <tr>
                            <th>Tempo richiesto : </th>
                            <td>
                                <table>
                                    <tr>
                                        <td><?= $oreTest ?> hh : <?= $minutiTest?> mm</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <th>Numero domande selezionate : </th>
                            <td><?= $numDomande?></td>
                        </tr>
                        <tr>
                            <th>Massimo punteggio test : </th>
                            <td><?= $totPunt ?></td>
                        </tr>
                        <tr>

                        </tr>
                        <tr>
                            <td colspan="2"></td>
                            <td><input type="submit" value="Continua" onclick="javascript:continua()" /></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div id="results">
                <div id="resultsCont">
                    <table id='tableResults' cellpadding='5' border="1">
                        <tr>
                            <th>Codice domanda</th>
                            <th>Domanda</th>
                            <th>Argomento</th>
                            <th>Tipologia</th>
                            <th>Dettaglio</th>
                        </tr>
                        <?
                        for($j=0; $j<count($domande); $j++)
                        {?>
                        <tr>
                            <td><?= $domande[$j]->getCodiceDomanda()?></td>
                            <td><?= $domande[$j]->getTestoDomanda()?></td>
                            <td><?= $domande[$j]->getNomeArgomento()?></td>
                            <td><?= $domande[$j]->getTipologia()?></td>
                            <td><a href='../report/detailQuestion.php?codiceDomanda=<?= $domande[$j]->getCodiceDomanda()?>'><img src='../images/icons/PNG/Magnifying Glass.png' height='30' width='30' title='Dettaglio domanda' border='0'/></a></td>
                        </tr>
                            <?}?>
                    </table>
                </div>
            </div>
        </center>
    </body>
</html>
